<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title><?= getValInArr(getSess(SESS_DIC), array('webInfo', 'webtitle')) ?></title>
  <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
  <meta content="yes" name="apple-mobile-web-app-capable" />
  <meta content="black" name="apple-mobile-web-app-status-bar-style" />
  <meta content="telephone=no" name="format-detection" />
  <script type="text/javascript" src="<?php echo base_url() . 'public/home/js/' ?>jquery.js"></script>
  <?php include_once "public/home/html/bootstrap.php"  ?>
  <link rel="stylesheet" href="<?php echo base_url() . 'public/h_ui/lib/Hui-iconfont/1.0.8/' ?>iconfont.css">
  <link rel="stylesheet" href="<?php echo base_url() . 'public/home/css/' ?>mui.min.css">
  <link rel="stylesheet" href="<?php echo base_url() . 'public/home/css/' ?>index.css">
  <?php include_once "public/home/html/alert.php"  ?>
  <script type="text/javascript" src="<?php echo base_url() . 'public/home/js/' ?>function.js"></script>
  <script src='<?php echo base_url() . 'public/home/mobile_date/' ?>jdate.min.js'></script>
  <?php include_once "public/home/html/mobile_dialog.php"  ?>
  <link rel="stylesheet" href="<?php echo base_url() . 'public/home/css/' ?>other.css">

</head>

<body>
  <style>
    body {
      padding: 3%;
      text-align: center;
      color: #3A3A3A;
      background-color: #f5f5f5;
      font-size: 16px
    }

    .aui-img-logo img {
      width: 80px;
      height: 80px;
      display: block;
      border: none;
      border-radius: 100%;
      margin: 0 auto;
    }

    li {
      list-style: none
    }

    .list-group-item {
      height: 50px;
      line-height: 25px
    }

    .col-xs-4 {
      color: #3A3A3A;
    }

    .col-xs-8 {
      color: #8C8C8C;
    }
  </style>
  <input type="hidden" name='url' value="<?php echo base_url(); ?>">
  <div class="search-head header mui-bar mui-bar-nav row" style="background-color: #f7f9fa; border:none;">
    <div class="col-xs-1" style="margin-top: 3%">
      <a class=" Hui-iconfont Hui-iconfont-slider-left" href="javascript:void(0)" onclick="history.back();" style="color: #C9C9C9"></a>
    </div>
    <div class="col-xs-11">
      <h1 class="mui-title" style="color:#333;margin-left: -5%">教学督导专题调研表提交</h1>
    </div>
  </div>

  <div class="add-container">
    <div class="mask-row">
      <div class="mask-row-l">文件名称</div>
      <div class="mask-row-r"><input type="text" name="file" value="" placeholder="请输入文件名称"></div>
    </div>
    <div class="mask-row">
      <div class="mask-row-l">调查题目</div>
      <div class="mask-row-r"><input type="text" name="title" value="" placeholder="请输入调查题目"></div>
    </div>
    <div class="mask-row">
      <div class="mask-row-l">调查人</div>
      <div class="mask-row-r role"><?= $_SESSION[SESS_USER_HOME]['username'] . '(' . $_SESSION[SESS_USER_HOME]['usercode'] . ')' ?></div>
    </div>
    <div class="mask-row">
      <div class="mask-row-l">督导身份</div>
      <div class="mask-row-r">
        <div class="mask-row-r-select">
          <select name="supervise" id="supervise">
          </select>
          <div class="select-btn Hui-iconfont Hui-iconfont-arrow2-bottom"></div>
        </div>
      </div>
    </div>
    <div class="mask-row">
      <div class="mask-row-l">时间</div>
      <div class="mask-row-r">
        <div id="listen_time"></div>
      </div>
    </div>
    <div class="mask-row">
      <div class="mask-row-l">调查内容（或情况）</div>
      <div class="mask-row-r"><textarea name="content" id="" cols="20" rows="5" placeholder="请输入调查内容（或情况）"></textarea></div>
    </div>
    <div class="mask-row">
      <div class="mask-row-l">意见或建议</div>
      <div class="mask-row-r"><textarea name="suggestion" id="" cols="20" rows="5" placeholder="请输入意见或建议"></textarea></div>
    </div>

    <div class="btn btn-danger radius saveBtn" onclick="save(this)">保存</div>

  </div>

  <script>
    $(function() {
      // getDocument();
      getAttendType();
    })
    // // 清空数据
    // function cancel() {
    //   $('input[name="file"]').val('');
    //   $('input[name="title"]').val('');
    //   $('textarea[name="suggestion"]').val('');
    //   $('textarea[name="content"]').val('');
    //   $('.role').text("<?=$_SESSION[SESS_USER_HOME]['username'].'('.$_SESSION[SESS_USER_HOME]['usercode'].')'?>");
    //   $('#listen_time').text('');
    //   $("#supervise option:first").prop("selected", 'selected');
    // }

    function getDate() {
      var _this = this;
      var nowTime = '';
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1;
      let dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate();
      nowDate = yy + "-" + mm + "-" + dd;
      return nowDate;
    }
    new Jdate({
      el: '#listen_time',
      format: 'YYYY-MM-DD',
      beginYear: 2020,
      endYear: 2050
    })

    // 保存添加
    function save(e) {
      var id = e.getAttribute('id')
      if (!id) {
        id = ''
      }
      var file = $('input[name="file"]').val();
      var title = $('input[name="title"]').val();
      var AttendType = $('select[name="supervise"]').find('option:selected').val();
      if (file == '') {
        $(document).dialog({
          content: '请输入文件名称',
        });
      } else if (title == '') {
        $(document).dialog({
          content: '请输入调查题目',
        });
      } else if (!AttendType) {
        $(document).dialog({
          content: '请选择督导身份',
        });
      } else {
        tableSave1(id)
      }
    }


    // 获取督导类型
    function getAttendType() {
      $.ajax({
        type: "POST",
        url: getRootPath() + '/Home/Other/getAttendType',
        data: {},
        dataType: "json",
        success: function(data) {
          console.log('getAttendType success', data)
          if (data.status == true) {
            var AttendType = data.res.AttendType
            for (var i = 0; i < AttendType.length; i++) {
              var demo = '<option value="' + AttendType[i].key + '">' + AttendType[i].value + '</option>';
              $('#supervise').append(demo);
            }
          }
        },
        error: function(data) {
          console.log('getAttendType error', data)
        }
      });
    }

    // 保存接口
    function tableSave1(id) {
      var name = $('input[name="file"]').val();
      var title = $('input[name="title"]').val();
      var advice = $('textarea[name="suggestion"]').val();
      var content = $('textarea[name="content"]').val();
      var sub_time = $('#listen_time').text();
      var AttendType = $('select[name="supervise"]').find('option:selected').val();
      $.ajax({
        type: "POST",
        url: getRootPath() + "/Home/Other/tableSave1",
        data: {
          id: id,
          name: name,
          advice: advice,
          content: content,
          sub_time: sub_time,
          title: title,
          AttendType: AttendType
        },
        dataType: "json",
        success: function(data) {
          console.log('tableSave1 success', data)
          if (data.status == true) {
            $(document).dialog({
              content: data.msg,
              onClickConfirmBtn: function() {
                history.back()
                // cancel()
              },
            });
          } else {
            $(document).dialog({
              content: data.msg,
            });
          }
        },
        error: function(data) {
          console.log('tableSave1 error', data)
        }
      });
    }
  </script>




</body>

</html>